import fetch from 'utils/fetch';


// 查看所有班级
export function classListData(ownerName, grade, className, classNum, schoolId, page, rows) {
    const data = {
        // proviceId, //省id
        // cityId, //市id
        // areaId, //区县id
        // schoolName, //学校名称
        ownerName, //班主任姓名
        grade, //年级
        className, //班级名称
        classNum, //班级编号
        schoolId
    };
    return fetch({
        url: `/eduClass/pageClass/${page}/${rows}`,
        method: 'post',
        data,
    });
}

//添加班级
export function addClassInfo(schoolId, grade, num) {
    const data = {
        schoolId,
        grade, //年级 q
        num, //班级数量
    };
    return fetch({
        url: '/eduClass/addClass',
        method: 'post',
        data,
    });
}

//设置班主任
export function setOwner(classId, ownerId, ownerName, schoolId) {
    const data = {
        classId,
        ownerId,
        ownerName,
        schoolId
    };
    return fetch({
        url: '/eduClass/updateOwner',
        method: 'post',
        data
    });
}

//获取班主任列表
export function getOwnerList(schoolId) {
    const data = {
        schoolId
    };
    return fetch({
        url: '/eduClass/listTeacherBySchool',
        method: 'post',
        data
    });
}

//获取班主任列表 搜索
export function listTeacherByName(schoolId, ownerName) {
    const data = {
        schoolId,
        ownerName
    };
    return fetch({
        url: "/eduClass/listTeacherByName",
        method: 'post',
        data
    })
}

//修改班昵称
export function changeClassName(classId, className) {
    const data = {
        classId,
        className
    };
    return fetch({
        url: '/eduClass/changeClassName',
        method: 'post',
        data,
    });
}


//分页查询班级学生信息

export function findStudentClassInfosByPage(page, rows, classId) {
    const data = {
        classId
    };
    return fetch({
        url: `/eduClassStudent/findStudentClassInfosByPage/${page}/${rows}`,
        method: 'post',
        data,
    });
}

//班级详情
export function getClassInfo(classId) {
    const data = {
        classId
    };
    return fetch({
        url: '/eduClass/getClassInfo',
        method: 'post',
        data
    })
}


//2. 删除班级学生
export function removeStudent(studentClassMapIds) {
    const data = {
        studentClassMapIds
    };
    return fetch({
        url: '/eduClassStudent/removeStudent',
        method: 'post',
        data,
    });
}
// created by cuihd at 20180713 调班改为异步的
// 批量删除班级学生轮询接口
export function removeStudentProgress(timeStamp) {
    const data = {
        timeStamp
    };
    return fetch({
        url: '/eduClassStudent/removeStudentProgress',
        method: 'post',
        data,
    });
}

//3. 离班(假删)
export function shiftStudent(studentClassMapIds) {
    const data = {
        studentClassMapIds
    };
    return fetch({
        url: '/shift/shiftStudent',
        method: 'post',
        data,
    });
}

//4. 导入班级学生
export function importStudent(classId) {
    const data = {
        classId
    };
    return fetch({
        url: '/eduClassStudent/importStudent',
        method: 'post',
        data,
    });
}
// created by cuihd at 20180713 调班改为异步的
// 批量导入学生轮询接口
export function importStudentProgress(timeStamp, classId) {
    const data = {
        timeStamp,
        classId
    };
    return fetch({
        url: '/eduClassStudent/importStudentProgress',
        method: 'post',
        data,
    });
}

//  导入班级学生 数据校验接口
export function verifyStudentForImport(classId, filePath) {
    const data = {
        classId,
        filePath
    };
    return fetch({
        url: '/eduClassStudent/verifyStudentForImport',
        method: 'post',
        data,
    });
}

//2. 获取班级信息
export function findClassInfoByClassId(classId) {
    const data = {
        classId
    };
    return fetch({
        url: `/eduClassStudent/findClassInfoByClassId/${classId}`,
        method: 'post',
        data,
    });
}
// edit by cuihd at 20180713 调班改为异步,接口改变
//调班/集体调班
export function changeStudentClass(studentsId, fromClassId, toClassId, fromGradeId, toGradeId) {
    const data = {
        studentsId,
        fromClassId,
        toClassId,
        fromGradeId,
        toGradeId
    };
    return fetch({
        // url: '/eduClassStudent/changeStudentClass',
        url: '/changeStudentClass/changeStudentClass',
        method: 'post',
        data,
    });
}

// created by cuihd at 20180713 调班改为异步的
// 学生调班轮询接口
export function changeStudentClassProgress(timeStamp, fromClassId, toClassId) {
    const data = {
        timeStamp,
        fromClassId,
        toClassId
    };
    return fetch({
        url: '/changeStudentClass/changeStudentClassProgress',
        method: 'post',
        data,
    });
}

//8. 根据学校id获取年级列表
export function getGradeList(schoolId) {
    const data = {
        schoolId
    };
    return fetch({
        url: '/class/getGradeList',
        method: 'post',
        data,
    });
}

//删除班级
export function deleteClass(classId) {
    const data = {
        classId
    };
    return fetch({
        url: '/eduClass/deleteClass',
        method: 'post',
        data,
    });
}

//9. 条件查询学校列表
export function getSchoolList(schoolName) {
    const data = {
        schoolName,
        // proviceId,
        // cityId,
        // areaId
    };
    return fetch({
        url: '/school/listSchoolByName',
        method: 'post',
        data,
    });
}

//10. 根据学校id查询年级列表
export function getGrade(schoolId) {
    const data = {
        schoolId
    };
    return fetch({
        url: '/eduClass/listGrade',
        method: 'post',
        data,
    });
}

//7. 获取班级编号
export function getClass(schoolId, grade) {
    const data = {
        schoolId,
        grade
    };
    return fetch({
        url: '/eduClass/listClassNum',
        method: 'post',
        data,
    });
}
//11. 根据年级和班级编号获取班级名称
export function getClassName(schoolId, grade, classNum, className) {
    const data = {
        schoolId,
        grade,
        classNum,
        className
    };
    return fetch({
        url: '/eduClass/getClassName',
        method: 'post',
        data,
    });
}

//13. 开启/禁用群聊
export function groupChart(classId, status) {
    const data = {
        classId,
        status, //（0：禁用，1：启用）
    };
    return fetch({
        url: '/eduClass/updateStatus',
        method: 'post',
        data,
    });
}

//新增学生
export function addStudentIntoClass(studentName, studentGender, schoolRollCode, birth, phone, classId, schoolId, phones) {
    const data = {
        studentName,
        studentGender,
        schoolRollCode,
        birth,
        phone,
        classId,
        schoolId,
        phones
    };
    return fetch({
        url: '/eduClassStudent/addStudentIntoClass',
        method: 'post',
        data,
    });
}

// 获取班级群聊信息详情
export function getGroupChatInfo(fClassId) {
    const data = {
        fClassId
    };
    return fetch({
        url: '/classGroupChat/getGroupChatInfo',
        method: 'post',
        data
    })
}

// 修改班级群聊公告
export function updateGroupChatNotice(noticeData) {
    const data = {
        ...noticeData
    };
    return fetch({
        url: '/classGroupChat/updateGroupChatNotice',
        method: 'post',
        data
    })
}


// 修改班级群聊头像
export function updateGroupChatImg(chatData) {
    const data = {
        ...chatData
    };
    return fetch({
        url: '/classGroupChat/updateGroupChatImg',
        method: 'post',
        data
    })
}

// 获取班级群聊的默认头像
export function getGroupChatDefaultImages(fClassId) {
    return fetch({
        url: '/classGroupChat/getGroupChatDefaultImages',
        method: 'post',
    })
}

// getBase64
export function base64ToFile(data) {
    
    return fetch({
        url: '/classGroupChat/upload',
        method: 'post',
        data
    })
}